﻿using System;
using System.Text;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Data.SqlClient;
using MySql.Data.MySqlClient;
public partial class SysRunSql : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection myConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["AUOOAMS"].ConnectionString);


        SqlHelper.ExecuteNonQuery(myConn, CommandType.Text, TextBox1.Text);


    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        SqlConnection myConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["AUOOAMS"].ConnectionString);


        GridView1.DataSource = SqlHelper.ExecuteDataset(myConn, CommandType.Text, TextBox1.Text);

        GridView1.DataBind();
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        MySqlCommand cmd;

        MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection(System.Configuration.ConfigurationManager.AppSettings["AUOOAMS"]);

        try
        {
            con.Open();
            cmd = new MySqlCommand(TextBox1.Text, con);
            cmd.ExecuteNonQuery();
            con.Close();
            Response.Write("完成");
        }
        catch (Exception ex)
        {
            con.Close();
            Response.Write(ex.Message );
        }
        finally
        {
           
        }
       

    }
    protected void Button4_Click(object sender, EventArgs e)
    {

        MySqlCommand cmd;

        MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection(System.Configuration.ConfigurationManager.AppSettings["AUOOAMS"]);

        try
        {
            con.Open();
            cmd = new MySqlCommand(TextBox1.Text, con);
            MySqlDataAdapter oDbAdapter;
            oDbAdapter = new MySqlDataAdapter(cmd);
            DataTable oTable;
            oTable = new DataTable();
            oDbAdapter.Fill(oTable);
            GridView1.DataSource = oTable;
            GridView1.DataBind();
            con.Close();
        }
        catch (Exception ex )
        {
            con.Close();
            Response.Write(ex.Message);
        }
        finally
        {

        }

    }
}
